#include <iostream>
#include <stdlib.h>  
#include <math.h> 
using namespace std;
class container {
protected:
    double r;
public:
    container(double r) : r(r) {}
    virtual double surface_area() const = 0;
    virtual double volume() const = 0;
    virtual void PrintInfo() const = 0;
};
class cube : public container {
public:
    double w;
    cube(double w) : container(w), w(w) {}
    double surface_area() const override {
        return 6 * w * w;
    }
    double volume() const override {
        return w * w * w;
    }
    void PrintInfo() const override {
        cout << "cube: 表面积 = " << surface_area() << endl;
        cout << "cube: 体积 = " << volume() << endl;
    }
};
class cylinder : public container {
public:
    double h;
    cylinder(double r, double h) : container(r), h(h) {}
    double surface_area() const override {
        return 2 * 3.14 * r * h + 2 * 3.14 * r * r;
    }
    double volume() const override {
        return 3.14 * r * r * h;
    }
    void PrintInfo() const override {
        cout << "cylinder: 表面积 = " << surface_area() << endl;
        cout << "cylinder: 体积 = " << volume() << endl;
    }
};
class sphere : public container {
public:
    sphere(double r) : container(r) {}
    double surface_area() const override {
        return 4 * 3.14 * r * r;
    }
    double volume() const override {
        return (4.0 / 3.0) * 3.14 * r * r * r;
    }
    void PrintInfo() const override {
        cout << "sphere: 表面积 = " << surface_area() << endl;
        cout << "sphere: 体积 = " << volume() << endl;
    }
};
int MyCompare(const void* s1, const void* s2) {
    const container* p1 = *(const container**)s1;
    const container* p2 = *(const container**)s2;
    double a1 = p1->volume();
    double a2 = p2->volume();

    if (a1 < a2)
        return -1;
    else if (a2 < a1)
        return 1;
    else
        return 0;
}

int main() {
    int i;
    int n;
    container** pShapes = new container * [n]; 
    cin >> n;

    for (i = 0; i < n; i++) {
        char c;
        cin >> c;
        switch (c) {
        case 'C': {
            double w;
            cin >> w;
            pShapes[i] = new cube(w);
            break;
        }
        case 'Y': {
            double r, h;
            cin >> r;
            cin >> h;
            pShapes[i] = new cylinder(r, h);
            break;
        }
        case 'S': {
            double r;
            cin >> r;
            pShapes[i] = new sphere(r);
            break;
        }
        }
    }

    qsort(pShapes, n, sizeof(container*), MyCompare);

    for (i = 0; i < n; i++) {
        pShapes[i]->PrintInfo();
    }

    for (i = 0; i < n; i++) {
        delete pShapes[i];
    }
    delete[] pShapes;

    return 0;
}